<template>
	<view class="item">
		<uv-skeletons :loading="loading" :skeleton="skeleton">
		</uv-skeletons>
		<navigator v-if="!isMore" :style="{display: loading ? 'hidden':''}" :url="'/pages/images/images?classid=' + value._id + '&name='+value.name" class="box">
			<image class="pic" :src="cloudIdToUrl(value.picurl,{w:'220rpx',h:'340rpx'})" mode="aspectFill" @load="picLoad"></image>
			<view class="title">{{value.name}}</view>
			<view class="date">
				<text>{{formatTimeDiff(value.updateTime)}}</text>
			</view>
		</navigator>
		<navigator v-if="isMore" :style="{display: loading ? 'hidden':''}" url="/pages/classify/classify" open-type="reLaunch" class="box more">
			<image class="pic" src="/common/images/more.jpg" mode="aspectFill" @load="picLoad"></image>
			<view class="title">
				<uni-icons type="more-filled" size="34" color="#fff"></uni-icons>
				<text class="text">更多</text>
			</view>
		</navigator>
	</view>
</template>

<script setup>
	import {ref} from 'vue'
	import { formatTimeDiff,cloudIdToUrl } from '@/utils/common.js'
	defineProps({
		isMore: {
			type: Boolean,
			default: false
		},
		value: {
			type: Object,
			default(){
				return {
					picurl:"../..//common/images/classify1.jpg",
					name:"默认标题",
					updateTime: Date.now()
				}
			}
		}
	})
	const loading = ref(true)
	const skeleton = ref([{
						type: 'line',
						num: 1,
						gap: '20rpx',
						style: ['width: 100%; height:340rpx']
					}])
					
	const picLoad = (e) => {
		loading.value = false
	}
</script>

<style lang="scss" scoped>
.item{
	.box{
		height: 340rpx;
		border-radius: 10rpx;
		overflow: hidden;
		position: relative;
		z-index: 1;
		.pic{
			width: 100%;
			height: 100%;
		}
		.title{
			position: absolute;
			z-index: 2;
			bottom: 0;
			left: 0;
			height: 70rpx;
			line-height: 70rpx;
			width: 100%;
			font-size: 30rpx;
			font-weight: 600;
			color: #fff;
			
			display: flex;
			justify-content: center;
			align-items: center;
			
			background-color: rgba(0,0,0,0.2); /* 半透明 */
			backdrop-filter: blur(20rpx); /* 磨砂玻璃效果 */
		}
		.date{
			position: absolute;
			top:0;
			left:0;
			background: rgba(250,129,90,0.7); 
			backdrop-filter: blur(20rpx); /* 磨砂玻璃效果 */
			color: #fff;
			font-size: 22rpx; /* 页面显示的最小是12px，如果小于这个也会按照12px进行，如果还想缩小则需要使用tranform */
			padding: 6rpx 14rpx;
			border-radius: 0 0 20rpx 0;
			transform: scale(0.8); /* 使用tranform改变元素大小 */
			transform-origin: left top;
		}
	}
	.box.more{
		.title{
			width: 100%;
			height: 100%;
			flex-direction: column;
			.text{
				font-size: 28rpx;
			}
		}
		
	}
}
</style>